home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Forward task *)
- (* *)
- (* Copyright 1988, 1989, 1990, 1991, 1992 by H. Roy Engehausen. All *)
- (* rights reserved. *)
- (* *)
- (*===========================================================================*)
-
- UNIT BBFWD;
-
- INTERFACE
-
- PROCEDURE forward_task_start;
-
- IMPLEMENTATION
-
- USES
- bbact,
- bbdummy,
- bbfwdd,
- bbfwdp,
- bbfwdr,
- bbhlook,
- bbmem,
- bbmisc6,
- bbsema2,
- bbsess,
- bbstr,
- bbtask,
- bbtime,
- bbwakeup,
- bbwin;
-
- PROCEDURE fwd_now(port_to_fwd : str8); FORWARD;
-
- (*===========================================================================*)
- (* Forward task control *)
- (*===========================================================================*)
-
- PROCEDURE forward_task_start;
-
- VAR
- fwd_to_ports : str8;
-
- BEGIN;
-
- (*-----------------------------------------------------------------------*)
- (* Add a wait *)
- (*-----------------------------------------------------------------------*)
-
- task_wait (2, FALSE);
-
- (*-----------------------------------------------------------------------*)
- (* Do this stuff first *)
- (*-----------------------------------------------------------------------*)
-
- load_action(#1);
-
- (*-----------------------------------------------------------------------*)
- (* This task loops forever *)
- (*-----------------------------------------------------------------------*)
-
- WHILE TRUE DO
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* Rotate tasks *)
- (*-------------------------------------------------------------------*)
-
- task_switch;
-
- (*-------------------------------------------------------------------*)
- (* Set port id.... *)
- (*-------------------------------------------------------------------*)
-
- active_port := @dummy_port;
- active_tcb^.port_chan_s := 'FO';
-
- (*-------------------------------------------------------------------*)
- (* Handle forward command *)
- (*-------------------------------------------------------------------*)
-
- IF fwd_command <> '' THEN
- BEGIN;
-
- (*---------------------------------------------------------------*)
- (* If not XSTOP then execute forward now *)
- (*---------------------------------------------------------------*)
-
- IF fwd_command <> 'XSTOP' THEN
- fwd_now('*');
-
- (*---------------------------------------------------------------*)
- (* Remove any XSTOP. If you are wondering why this is a *)
- (* separate statement instead of being an ELSE off the previous *)
- (* one, it is because the FWD_NOW can take hours to return! *)
- (* The removal of XSTOP is needed in that case so we don't *)
- (* accidently abort a timed forward when we have aborted a *)
- (* commanded "forward". This was learned by experience! *)
- (*---------------------------------------------------------------*)
-
- IF fwd_command = 'XSTOP' THEN
- fwd_command := '';
-
- END;
-
- (*-------------------------------------------------------------------*)
- (* Handle forward time. *)
- (*-------------------------------------------------------------------*)
-
- fwd_to_ports := find_forward_port;
-
- IF fwd_to_ports <> '' THEN
- BEGIN;
-
- active_port := @dummy_port;
-
- (*---------------------------------------------------------------*)
- (* Hlookup *)
- (*---------------------------------------------------------------*)
-
- IF opt_block.opt_auto_hlookup THEN
- BEGIN;
- fwd_out_busy := TRUE;
- h_look_up('GH');
- fwd_out_busy := FALSE;
- END;
-
- (*---------------------------------------------------------------*)
- (* Forward to the port *)
- (*---------------------------------------------------------------*)
-
- fwd_now(fwd_to_ports);
-
- (*---------------------------------------------------------------*)
- (* Remove an XSTOP if any *)
- (*---------------------------------------------------------------*)
-
- IF fwd_command = 'XSTOP' THEN
- fwd_command := '';
-
- (*---------------------------------------------------------------*)
- (* Schedule next forward *)
- (*---------------------------------------------------------------*)
-
- sked_forward_port(fwd_to_ports);
-
- (*---------------------------------------------------------------*)
- (* Force some relief to other tasks *)
- (*---------------------------------------------------------------*)
-
- task_switch;
-
- END;
-
- active_port := @dummy_port;
-
- (*-------------------------------------------------------------------*)
- (* WAKEUP time???? *)
- (*-------------------------------------------------------------------*)
-
- IF (wakeup_time < current_day_time) OR (wakeup_force) THEN
- BEGIN;
- fwd_out_busy := TRUE;
- wakeup_force := FALSE;
- wakeup;
- fwd_out_busy := FALSE;
- END;
-
- END; (*----- End of forever loop --------------------------------------*)
-
- END;
-
- (*===========================================================================*)
- (* Forward now *)
- (*===========================================================================*)
-
- PROCEDURE fwd_now(port_to_fwd : str8);
-
- VAR
- path_common : path_block;
- sked_port : port_block_ptr;
-
- BEGIN;
-
- (*-----------------------------------------------------------------------*)
- (* Mark that we are forwarding *)
- (*-----------------------------------------------------------------------*)
-
- fwd_out_busy := TRUE;
-
- WITH path_common DO
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* Initialize the path block *)
- (*-------------------------------------------------------------------*)
-
- FILLCHAR(path_common, SIZEOF(path_common), CHR(0));
-
- path_sub_sw := TRUE;
-
- (*-------------------------------------------------------------------*)
- (* Check where command came from *)
- (*-------------------------------------------------------------------*)
-
- IF port_to_fwd <> '*' THEN
-
- (*-----------------------------------------------------------------*)
- (* Command via port start *)
- (*-----------------------------------------------------------------*)
-
- path_port_p := port_to_fwd
-
- ELSE
- BEGIN;
-
- (*---------------------------------------------------------------*)
- (* Command via console, check for options *)
- (*---------------------------------------------------------------*)
-
- (*---------------------------------------------------------------*)
- (* Port option process *)
- (*---------------------------------------------------------------*)
-
- IF subword(@fwd_command, 2, 1) = 'PORT' THEN
- BEGIN;
-
- (*-----------------------------------------------------------*)
- (* Port option! Remove the word PORT *)
- (*-----------------------------------------------------------*)
-
- fwd_command := subword(@fwd_command, 3, 0);
-
- (*-----------------------------------------------------------*)
- (* If here is something following the word, save it as *)
- (* the port name *)
- (*-----------------------------------------------------------*)
-
- IF LENGTH(fwd_command) <> 0 THEN
- path_port_p := fwd_command
- ELSE
- path_port_p := '?';
-
- (*-----------------------------------------------------------*)
- (* Remove the port name from the command *)
- (*-----------------------------------------------------------*)
-
- fwd_command := subword(@fwd_command, 2, 0);
-
- END
- ELSE
- BEGIN;
-
- (*-----------------------------------------------------------*)
- (* Port option not specified. Remove front of command *)
- (*-----------------------------------------------------------*)
-
- fwd_command := subword(@fwd_command, 2, 0);
-
- (*-----------------------------------------------------------*)
- (* Set to any port *)
- (*-----------------------------------------------------------*)
-
- path_port_p := '*';
-
- END;
-
- (*---------------------------------------------------------------*)
- (* If the word FORCE was specified, set the flag for it *)
- (*---------------------------------------------------------------*)
-
- path_pattern := 'FORCE';
- IF find(@fwd_command, @path_pattern) <> 0 THEN
- path_force_sw := TRUE;
-
- (*---------------------------------------------------------------*)
- (* Save the path pattern *)
- (*---------------------------------------------------------------*)
-
- path_pattern := subword(@fwd_command, 1, 1);
-
- (*---------------------------------------------------------------*)
- (* Eradicate the forward command buffer to ready it for next *)
- (* time *)
- (*---------------------------------------------------------------*)
-
- fwd_command := '';
-
- END;
-
- (*-------------------------------------------------------------------*)
- (* If a path pattern wasn't specified, assume one *)
- (*-------------------------------------------------------------------*)
-
- IF path_pattern = '' THEN
- path_pattern := '*';
-
- (*-------------------------------------------------------------------*)
- (* Tell operator what is happening *)
- (*-------------------------------------------------------------------*)
-
- window_write('FO::', '====> Forward cycle start -- '
- + path_port_p + ' -- '
- + path_pattern + ' <====' );
-
- (*-------------------------------------------------------------------*)
- (* Switch away for once *)
- (*-------------------------------------------------------------------*)
-
- task_switch;
-
- (*-------------------------------------------------------------------*)
- (* Process routes *)
- (*-------------------------------------------------------------------*)
-
- do_route;
-
- (*-------------------------------------------------------------------*)
- (* Switch away for once *)
- (*-------------------------------------------------------------------*)
-
- task_switch;
-
- (*-------------------------------------------------------------------*)
- (* Process paths *)
- (*------------------------------------------------------------------*)
-
- IF NOT msg_route_force THEN
- do_path(@path_common);
-
- (*-------------------------------------------------------------------*)
- (* Clean things up *)
- (*-------------------------------------------------------------------*)
-
- free_semaphore(semaphore_fwd_route_use);
-
- free_task_mem_all(active_tcb);
-
- (*-------------------------------------------------------------------*)
- (* Tell operator we are done *)
- (*-------------------------------------------------------------------*)
-
- window_write('FO::', '=====> Forward cycle end <=====');
-
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Forward complete *)
- (*-----------------------------------------------------------------------*)
-
- fwd_out_busy := FALSE;
-
- END;
-
- END.